package com.lipy.dubboconsumer.controller;

import com.lipy.dubbocommon.entity.Staff;
import com.lipy.dubboconsumer.service.CacheDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("cache")
public class CacheController {
    @Autowired
    CacheDemoService cacheDemoService;
    @GetMapping("get/{id}")
    public Object getCache(@PathVariable("id")Integer id){
        System.out.println("CacheController.getCache");
        Staff staff = cacheDemoService.get(id);
        return staff;
    }
    @GetMapping("save")
    public Object saveStaff(){
        Staff staff = new Staff();
        staff.setId(1);
        staff.setName("1namesave");
        cacheDemoService.save(staff);
        System.out.println("CacheController.saveStaff");
        return "ok";
    }
    @GetMapping("delete/{id}")
    public Object delete(@PathVariable("id") Integer id){
        int delete = cacheDemoService.delete(id);
        System.out.println("CacheController.delete rows"+delete);
        return delete;
    }
}
